package com.assignwork.service.impl;

import com.assignwork.dto.TrainStatisticsItemDTO;
import com.assignwork.vo.TrainStatisticsItemVO;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springblade.core.mp.base.BaseServiceImpl;
import com.assignwork.entity.TrainStatisticsItem;
import com.assignwork.mapper.TrainStatisticsItemMapper;
import com.assignwork.service.ITrainStatisticsItemService;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * (TrainStatisticsItem)表服务实现类
 */
@AllArgsConstructor 
@Service("trainStatisticsItemService")
public class TrainStatisticsItemServiceImpl extends BaseServiceImpl<TrainStatisticsItemMapper, TrainStatisticsItem> implements ITrainStatisticsItemService {

    @Override
    public boolean saveDtos(List<TrainStatisticsItemDTO> dtos) {
        List<TrainStatisticsItem> collect = dtos.stream().map(TrainStatisticsItemDTO::toEtt).collect(Collectors.toList());
        return this.saveBatch(collect);
    }

    @Override
    public List<TrainStatisticsItemVO> listByParentId(Long id) {
        return this.baseMapper.listByParentId(id);
    }
}
